#pragma once
#include "include.h"

int generate_oneball() {
	int i = 0;
	for (i = 0; i < 40; i++) {
		if (Balls[i].type == -1) {
			break;
		}
	}
	srand((unsigned)time(NULL));
	int random = rand() % 5;
	Balls[i].x = Mouse.x;
	Balls[i].y = Ini_Y;
	Balls[i].type = random;
	switch (random) {
	case 0:
		Balls[i].r = 20;
		loadimage(Balls[i].img, _T(".\\Source\\Picture\\1.png"));break;
	case 1:
		Balls[i].r = 25;
		loadimage(Balls[i].img,_T(".\\Source\\Picture\\2.png")); break;
	case 2:
		Balls[i].r = 30; 
		loadimage(Balls[i].img, _T(".\\Source\\Picture\\3.png")); break;
	case 3:
		Balls[i].r = 40; 
		loadimage(Balls[i].img, _T(".\\Source\\Picture\\4.png")); break;
	case 4:
		Balls[i].r = 55; 
		loadimage(Balls[i].img, _T(".\\Source\\Picture\\5.png")); break;
	}
	return i;
}

void generate_Ball() {
	int i = generate_oneball();
	if (Mouse.x < Balls[i].r) {
		Balls[i].x = Balls[i].r;
	}
	else if (Mouse.x > WIDTH - Balls[i].r) {
		Balls[i].x = WIDTH - Balls[i].r;
	}
}